package com.ruoyi.goods.api.factory;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.goods.api.RemoteGoodsService;
import com.ruoyi.goods.api.domain.BmPreferential;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author {那蓝桉}
 * @Date: 2023/08/05/ 10:24
 * @description   商品降级处理
 */
@Component
public class RemoteGoodsFallbackFactory implements FallbackFactory<RemoteGoodsService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteGoodsFallbackFactory.class);

    @Override
    public RemoteGoodsService create(Throwable cause) {
        log.error("商品服务调用失败:{}", cause.getMessage());
        return new RemoteGoodsService() {
            @Override
            public Integer getGoodsNumByWarehouseCode(String warehouseCode) {
                return null;
            }

            @Override
            public AjaxResult queryAll() {
                return AjaxResult.error();
            }

            @Override
            public AjaxResult queryByStartTime() {
                return AjaxResult.error();
            }

            @Override
            public AjaxResult updateStatus(Long id) {
                return AjaxResult.error();
            }

            @Override
            public AjaxResult updateStatus0(Long id) {
                return AjaxResult.error();
            }

        };
    }
}
